<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>家长管理</title>
<%@ include file="../../common/importLib.jsp" %>
<script type="text/javascript">
	/**
	 * 增删改查参数设置
	 */
	tableTitle = "家长表";
	tableURL = getTimeURL("userInfo/userList.do?roleId=3");
	toolbarView = 2;
	tableColumns = [[{field:'ck',checkbox:true},
	                {field:'id',title:'id',width:0,rowspan:1},	
	                {field:'picName',title:'照片',width:60,rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.picName==""){
								return "";
							}else{
								var url="maintain/userpic/"+rowData.picName+"?"+new Date().getTime();
								return "<img onclick=\"viewPic('"+url+"')\" src='"+url+"' style='width:50px;height:40px;'/>";
							}
						}},
					{field:'loginCode',title:'账号',width:120,rowspan:1},	
					{field:'userName',title:'姓名',width:100,rowspan:1},
					{field:'sex',title:'性别',width:70,rowspan:1},
					{field:'email',title:'邮箱',width:100,rowspan:1},	
					{field:'mobilePhone',title:'手机号码',width:100,rowspan:1},
					{field:'birthday',title:'生日',width:100,rowspan:1},
					{field:'phone',title:'电话',width:100,rowspan:1},
					{field:'qq',title:'QQ',width:100,rowspan:1},	
					{field:'registerDateString',title:'注册日期',width:100,rowspan:1},
					{field:'province',title:'省份',width:70,rowspan:1},
					{field:'city',title:'城市',width:70,rowspan:1},	
					{field:'county',title:'区域',width:70,rowspan:1},
					{field:'street',title:'街道地址',width:120,rowspan:1},	
					{field:'userDesc',title:'个人简介',width:180,rowspan:1},
					{field:'roleName',title:'角色名称',width:70,rowspan:1},
					{field:'schoolName',title:'学校名称',width:150,rowspan:1},
					{field:'disableFlag',title:'禁用状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.disableFlag == 0){
								return "<font color='green'>起用</font>";
							}else{
								return "<font color='red'>禁用</font>";
							}
						}
					}]];
	
	

	var addWidth = 700; //添加窗口宽度
	var addHeight = 350; //添加窗口高度
	var addTitle = "添加家长"; //添加标题
	var updateWidth = 700; //修改窗口宽度
	var updateHeight = 450; //修改窗口高度
	var updateTitle = "修改家长信息"; //修改标题
	var updateDisableFlagUri = "userInfo/updateDisableFlag.do"; //禁用、起用记录
	var deleteUri = "userInfo/deleteByIds.do"; //删除记录
	
	/**
	 * 初始化添加表单
	 */	
	function initAddForm(){	
		openPicUpload();
		$("#roleId").val("4");
		addFormProcess("loginCode","用户",true);	
		ajaxFormValidator("loginCode","账号",1,16,"userInfo/loginCodeValidate.do","ascii");
		baseFormValidator("userName","姓名",2,12,"chinese");
		baseFormValidator("mobilePhone","电话",11,11,"mobile");
	}
	
	/**
	 * 初始化修改表单
	 */
	function initUpdateForm(jsonObject){
		//selectRadio(jsonObject.sex,"datagrid_update");
		$("#picNameUpdate").val(jsonObject.picName);
		openPicUploadUpdate();
		$("#roleIdUpdate").val("4");
		$("#loginCodeUpdate").html(jsonObject.loginCode);
		$("#userNameUpdate").val(jsonObject.userName);
		$("#idUpdate").val(jsonObject.id);
		$("#emailUpdate").val(jsonObject.email);
		$("#mobilePhoneUpdate").val(jsonObject.mobilePhone);
		$("#birthdayUpdate").val(jsonObject.birthday);
		$("#phoneUpdate").val(jsonObject.phone);
		$("#qqUpdate").val(jsonObject.qq);
		$("#streetUpdate").val(jsonObject.street);
		$("#userDescUpdate").val(jsonObject.userDesc);
		$("#streetUpdate").val(jsonObject.street);
		$("#city_4Update").citySelect({prov:jsonObject.province, city:jsonObject.city, dist:jsonObject.county});
		updateFormProcess("userName","用户");	
		baseFormValidator("userNameUpdate","姓名",2,12,"chinese");
		baseFormValidator("mobilePhoneUpdate","电话",11,11,"mobile");
	}
	
	/**
	 *打开照片上传组件
	 */
	function openPicUpload(){
		uploadOneFile("uploadFile","/mrjy_file/common/util/upload.do","1000KB",100,30,"uploadMessage","backup/maintain/userpic/","picName");
	}
	function openFileUpload(){
		uploadOneFile("uploadFileImport","/mrjy_file/common/util/upload.do","20000KB",100,30,"uploadMessageImport","backup/maintain/userxls/","fileName");
	}
	/**
	 *打开修改照片上传组件
	 */
	function openPicUploadUpdate(){
		uploadOneFile("uploadFileUpdate","/mrjy_file/common/util/upload.do","1000KB",100,30,"uploadMessageUpdate","backup/maintain/userpic/","picNameUpdate");
	}
	
</script>
<script type="text/javascript">
$(function(){
	$("#city_4").citySelect({    	
	}); 
});
</script>
</head>
<body id="layout" class="easyui-layout">
	<div style="background: none repeat scroll 0% 0% #EFEFEF; height:75px; padding: 6px 2px; border-bottom: 1px solid #CCC;"
		region="north"  split="false" title="条件查询">
	<form  id="searchForm" >
	<table>
		<tr>
			<td>家长名称：</td><td><input type="text" name="userName"/> </td>			
			<td>家长账号：</td><td><input type="text" name="loginCode"/> </td>			
			<td><a class="easyui-linkbutton" id="search" iconCLs="icon-search"  onclick="searchTable()">搜索</a></td>
			<td><a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('searchForm').reset();reload();">清空</a></td>
			
			<td width="50px;"></td>			
			<td colspan="2"><a class="easyui-linkbutton" id="search" iconCls="icon-add" onclick="openImport()">批量导入学生信息</a></td>
		</tr>
	</table>
	</form>
	</div>
	<div region="center">
	<!-- datagrid信息表 -->
	<table id="datagrid_table"></table>
	</div>
	<!-- 添加记录 -->
	<div id="datagrid_add">
		<form id="add_form" action="userInfo/maintainAddUserInfo.do" method="post">
			<input type="hidden" id="picName" name="picName" onclick='openPicUpload()'>
			<input type ="hidden" id="roleId" name="roleId">
			<table width="630" class="xxl_tb_1">
				<tbody>	
					<tr>
						<td width="120" class="xxl_td_2">账号：</td>
						<td ><input type="text" id="loginCode" name="loginCode" onchange="validateSubmitOnce=true"/></td>
						<td><div id="loginCodeTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">姓名：</td>
						<td><input type="text" id="userName" name="userName"/></td>
						<td><div id="userNameTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">手机号码：</td>
						<td><input type="text" id="mobilePhone" name="mobilePhone" maxlength="11"/></td>
						<td><div id="mobilePhoneTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2"></td>
						<td><div style="width:250px;color: red">*学生的默认密码是：123abc</div></td>
						<td></td>
					</tr>
					<tr>
						<td colspan="3" style="text-align: center">					
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#add_form').submit();">添加</a>
							<a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('add_form').reset()">重置</a>
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_add').window('close');">取消</a>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
	<!-- 修改记录 -->
	<div id="datagrid_update">
		<form id="update_form" action="userInfo/updateById.do" method="post">
			<input type="hidden" id="idUpdate" name="id"/>
			<input type ="hidden" id="roleIdUpdate" name="roleId">
			<input type="hidden" id="picNameUpdate" name="picName" onclick='openPicUploadUpdate()'>
			<table width="630" class="xxl_tb_1">
				<tbody>
					<tr>
						<td class="xxl_td_2">账号：</td>
						<td colspan="2" id="loginCodeUpdate"></td>
					</tr>
					<tr>
						<td class="xxl_td_2">姓名：</td>
						<td><input type="text" id="userNameUpdate" name="userName"/></td>
						<td><div id="userNameUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr height="40">
						<td class="xxl_td_1">上传照片：</td>
						<td colspan="2"><input id='uploadFileUpdate' type='file' name='uploadFile'/><span id='uploadMessageUpdate' style='margin-left:10px'></span></td>	
					</tr>
					<tr>
						<td class="xxl_td_2">邮箱：</td>
						<td><input type="text" id="emailUpdate" name="email" onchange="validateSubmitOnce=true"/></td>
						<td><div id="emailUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">手机号码：</td>
						<td><input type="text" id="mobilePhoneUpdate" name="mobilePhone" maxlength="11"/></td>
						<td><div id="mobilePhoneUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">固定电话：</td>
						<td><input type="text" id="phoneUpdate" name="phone"/></td>
						<td><div id="phoneUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">性别：</td>
						<td><input name="sex" type="radio" value="男" class="radio-option"/>男
							<input name="sex" type="radio" value="女" class="radio-option"/>女</td>
						<td></td>
					</tr>
					<tr>
						<td class="xxl_td_2">生日：</td>
						<td><input type="text" id="birthdayUpdate" name="birthday" onClick="WdatePicker()"/></td>
						<td></td>
					</tr>
					<tr>
						<td class="xxl_td_2">QQ：</td>
						<td><input type="text" id="qqUpdate" name="qq" maxlength="10"/></td>
						<td><div id="qqUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td  class="xxl_td_2">学校地址：</td>
						<td ><div id="city_4Update">
								<select class="prov" name="province" id="province"></select> 
								<select class="city" disabled="disabled" name="city" id="city"></select>
								<select class="dist" disabled="disabled" name="county" id="county"></select>
							</div>
						</td>
						<td ></td>
					</tr>				
					<tr>
						<td class="xxl_td_2">街道地址：</td>
						<td><input type="text" id="streetUpdate" name="street"/></td>
						<td></td>
					</tr>
					<tr>
						<td class="xxl_td_2">个人介绍：</td>
						<td><textarea id="userDescUpdate" name="userDesc" cols="30"></textarea></td>
						<td><div id="userDescUpdateTip" style="width:250px"></div></td>
					</tr>
					
					<tr>
						<td colspan="3" style="text-align: center">
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#update_form').submit();">修改</a>		
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_update').window('close');">取消</a>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
</body>
</html>